package com.shenmazg6.controller;


import com.shenmazg6.service.TbUserService;
import com.shenmazg6.utils.ResultResponse;
import com.shenmazg6.vo.LoginInfoVo;
import com.shenmazg6.vo.PageInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


@RestController
@Slf4j
@RequestMapping(value = "/user")
public class TbUserController {

    @Autowired
    TbUserService tbUserService;


    @PostMapping(value = "/login")
    public ResultResponse login(@RequestBody @Valid LoginInfoVo loginInfoVo) {
        return tbUserService.login(loginInfoVo);
    }

    @PostMapping(value = "/login2")
    public ResultResponse login2(@RequestBody @Validated LoginInfoVo loginInfoVo) {
        return tbUserService.login(loginInfoVo);
    }

    @PostMapping(value = "/list")
    public ResultResponse list(@RequestBody @Valid PageInfoVo pageInfoVo) {
        return tbUserService.listByPage(pageInfoVo);
    }
}
